﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;
using System.Diagnostics;
using System.Windows.Media;

namespace UML_Creator.Model
{
    public class PolygonConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //This class returns a string of the format x,y "x,y x,y x,y"
            //value should be the X coordinate
            //parameter should be the Y coordinate
            Point p = new Point(double.Parse(values[0].ToString()), double.Parse(values[1].ToString()));
            double x1, y1, x2, y2, x3, y3, x4, y4;
            x1 = p.X;//Bottom corner
            y1 = p.Y-10;//Bottom corner
            x3 = x1; //Top corner
            y3 = ((y1) + 10);//Top corner
            x2 = ((x1) - 5);//Left corner
            y2 = ((y1) + 5);//Left corner
            x4 = ((x1) + 5); ;//Right corner
            y4 = ((y1) + 5);//Right corner

            PointCollection pc = new PointCollection(4);
            Debug.WriteLine("Points for polygon: "+x1 +","+y1+" "+ x2 + ","+y2+" "+x3+","+y3+" "+x4+","+y4);
            pc.Add(new Point(x1,y1));
            pc.Add(new Point(x2, y2));
            pc.Add(new Point(x3, y3));
            pc.Add(new Point(x4, y4));
            
            return pc;
   
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
